package com.wh.nio.tcplong.client;

import java.io.OutputStream;
import java.net.Socket;
import java.util.concurrent.ConcurrentLinkedQueue;

import com.wh.nio.tcplong.protocol.BasicProtocol;

public class RequestTask implements Runnable {
	
	private static final String ADDRESS = "192.168.1.1";
	private static final int PORT = 3333;
	private static final int SUCCESS = 100;
	private static final int FAILED = -1;
	private String uuid;
	private Socket socket;
	private Object lockObj = new Object();
	private ConcurrentLinkedQueue<BasicProtocol> sendDatas = new ConcurrentLinkedQueue<BasicProtocol>();
	private ConcurrentLinkedQueue<BasicProtocol> receDatas = new ConcurrentLinkedQueue<BasicProtocol>();
	
	

	@Override
	public void run() {
		
	}

	
	//write 当没有发送的数据时让发送线程进行等待
	public class SendTask extends Thread {
		
		private boolean isCancle = false;
		private OutputStream outputStreamSend;
		
		@Override
		public void run() {
			while(!isCancle) {
				printMessage();
				BasicProtocol basicProtocol = sendDatas.poll();
				if(basicProtocol == null) {
					towait();
				}
			}
		}
		
	}
	
    public void printMessage(){
    }
    
    private void towait() {
    	synchronized (lockObj) {
    		try {
				lockObj.wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
    }
}
